﻿using AutoMapper;
using Comm100.Application.Services;
using Comm100.Framework.Auditing;
using Comm100.Framework.Authorization;
using Comm100.Public.Audit;
using Bot.Application.Dto;
using Bot.Application.Services;
using Bot.Domain.Bo;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using Bot.Domain;

namespace Bot.Application.AnswerInChannelForms.Service
{
    public class AnswerInChannelFormAppService : BaseAppService, IAnswerInChannelFormAppService
    {
        private IAnswerInChannelFormDomainService _domainService;

        public AnswerInChannelFormAppService(IAnswerInChannelFormDomainService domainService) : base()
        {
            this._domainService = domainService;
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELFORM, AuditAction.DESTROY)]
        public void Delete(Guid id)
        {
            _domainService.Delete(id);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELFORM, AuditAction.CREATE)]
        public AnswerInChannelFormDto Add(Guid answerInChannelId, AnswerInChannelFormCreateDto dto)
        {
            AnswerInChannelForm answerInChannelForm = _domainService.CreateWithAnswerInChannelId(answerInChannelId, Mapper.Map<AnswerInChannelForm>(dto));
            return Mapper.Map<AnswerInChannelFormDto>(answerInChannelForm);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELFORM, AuditAction.UPDATE)]
        public AnswerInChannelFormDto Update(Guid id, AnswerInChannelFormUpdateDto dto)
        {
            AnswerInChannelForm answerInChannelForm = _domainService.Update(Mapper.Map<AnswerInChannelFormUpdateBo>(dto));
            answerInChannelForm.Id = id;
            return Mapper.Map<AnswerInChannelFormDto>(answerInChannelForm);
        }

        public AnswerInChannelFormDto Get(Guid id)
        {
            AnswerInChannelForm answerInChannelForm = _domainService.Get(id);
            return Mapper.Map<AnswerInChannelFormDto>(answerInChannelForm);
        }
        public AnswerInChannelFormDto GetByAnswerInChannelId(Guid answerInChannelId, string include="")
        {
            AnswerInChannelForm answerInChannelForm = _domainService.GetByAnswerInChannelId(answerInChannelId, include);
            return Mapper.Map<AnswerInChannelFormDto>(answerInChannelForm);
        }

        public IEnumerable<AnswerInChannelFormDto> GetList()
        {
            IEnumerable<AnswerInChannelForm> list = _domainService.List();
            return Mapper.Map<IEnumerable<AnswerInChannelFormDto>>(list);
        }
    }
}
